<template>
    <div class="ml-invest">
    	<div v-html="pdfurls"></div>
    </div>
</template>

<script>
import request from "../../config/request.js"
import {bus} from "../../config/bus.js"
import bridge from "../../config/jsBridge.js"
import judgeSystem from "../../config/judgeSystem.js"
export default {
    data(){
        return{
             pdfurls:''
        }
    },
    created(){
    	if(this.$route.params.sid==undefined){
	     	bridge.set(function(bridge){
				bridge.init();
				bridge.callHandler('sid',{},function(responseData) {
				})
			})   		
    	}
//  	request.getProtocolInvest({'itemId':this.$route.params.userItemId},function(res){
//			res.data = res.data.replace(/[\r\n]+/gi,"<br>");
//			self.pdfurls = res.data + "<br>";
//			//document.getElementById("investContent").innerText = res.data;
//  	});
    	bridge.set(function(bridge){
			bridge.init();
//			bridge.callHandler('sid',{},function(responseData) {
//			})
		})
    	
    },
    mounted(){
    	var self = this;
    	console.log(navigator.userAgent);
    	var detect = judgeSystem.detect(navigator.userAgent);
		var system;
		console.log(detect);
		if(detect.os.ios){
			system = 'ios';
		}else{
			system = 'android';
		}
		if(this.$route.params.sid!=undefined){
	            	self.$.ajax({ 
						url:'/fish-backend/apis/item/protocol',   //提交的url
				        type:'GET',
				        data:{'itemId':self.$route.params.userItemId},
				        beforeSend:function(xhr){		  	        		
				        		xhr.setRequestHeader('sid',this.$route.params.sid);
				        		xhr.setRequestHeader('softversion',detect.app.Xylc);
				        		xhr.setRequestHeader('appidentifier',system);	
				        		xhr.setRequestHeader('source','web');
				        		xhr.setRequestHeader('channel','yingyu686');	
				        },
				        success:function(res){
							res.data = res.data.replace(/[\r\n]+/gi,"<br>");  
							self.pdfurls = res.data + "<br>";
				        }
					});				
		}else{
			this.bridge.callHandler('sid',{},function(responseData) {
		            	self.$.ajax({ 
							url:'/fish-backend/apis/item/protocol',   //提交的url
					        type:'GET',
					        data:{'itemId':self.$route.params.userItemId},
					        beforeSend:function(xhr){		  	        		
					        		xhr.setRequestHeader('sid',responseData);
					        		xhr.setRequestHeader('softversion',detect.app.Xylc);
					        		xhr.setRequestHeader('appidentifier',system);	
					        		xhr.setRequestHeader('source','web');
					        		xhr.setRequestHeader('channel','yingyu686');	
					        },
					        success:function(res){
								res.data = res.data.replace(/[\r\n]+/gi,"<br>");  
								self.pdfurls = res.data + "<br>";
					        }
						});			
			})			
		}
    }
 }
</script>
<style lang="scss">
.ml-invest{
	height:100%;
	padding:30px 30px 0;
	div{
		line-height:40px;
		text-align: justify;
		margin-bottom:30px;
		font-family: PingFangSC-Regular;
		font-size: 26px;
		color: #464646;
	}
}		
</style>